<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format"
	xmlns:fop="http://xmlprint.eu/xml/fo-plus" version="2.0">

	<xsl:output method="xml" version="1.0" indent="no" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" />

	<xsl:template match="/">
		<fo:root>
			<fo:declarations>
				<xsl:call-template name="setupFields" />
			</fo:declarations>
			<xsl:call-template name="setupPagemasters" />
			<xsl:call-template name="mainAction" />
		</fo:root>
	</xsl:template>

	<xsl:template name="setupPagemasters">
	</xsl:template>

	<xsl:template name="setupFields">
	</xsl:template>
	
	<xsl:template name="setupHeaderFooter">
	</xsl:template>
	
	<xsl:template name="setFOStatic">
		<xsl:param name="pm"/>
	</xsl:template>
	
	
	<xsl:variable name="openPageSequence1"><![CDATA[<fo:page-sequence master-reference="]]></xsl:variable>
    
    <xsl:variable name="openPageSequence2"><![CDATA[">]]></xsl:variable>
    
    <xsl:variable name="openPageSequence3"><![CDATA[<fo:flow flow-name="xsl-region-body">]]></xsl:variable>
    
    <xsl:variable name="closePageSequence">
    <![CDATA[</fop:columns>
    </fo:flow>
    </fo:page-sequence>]]>
    </xsl:variable>
    
    <xsl:template name="newPageSequence">
        <xsl:param name="masterreference"/>
        <xsl:value-of select="$closePageSequence" disable-output-escaping="yes"/>
        <xsl:value-of select="$openPageSequence1" disable-output-escaping="yes"/>
        <xsl:value-of select="$masterreference"/>
        <xsl:value-of select="$openPageSequence2" disable-output-escaping="yes"/>
        <!--<xsl:call-template name="setFOStatic">
        	<xsl:with-param name="pm" select="$masterreference"/>
     </xsl:call-template>
        <xsl:value-of select="$openPageSequence3" disable-output-escaping="yes"/>-->
    </xsl:template>

	<xsl:template name="mainAction">
		<xsl:call-template name="setupHeaderFooter" />
			<fo:flow flow-name="xsl-region-body">
				<fop:columns xsl:use-attribute-sets="standard">
					<xsl:apply-templates />
				</fop:columns>
			</fo:flow>
	</xsl:template>

	<xsl:template match="*" priority="-100">
		<xsl:apply-templates />
	</xsl:template>
</xsl:stylesheet>

